package com.lc.luzhengtang.adapter;

import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lc.luzhengtang.R;
import com.lc.luzhengtang.activity.ClassficationDetailActivity;
import com.lc.luzhengtang.bean.ClassFication;
import com.lc.luzhengtang.conn.Conn;
import com.zcx.helper.scale.ScaleScreenHelperFactory;

import java.util.List;

/**
 * 文 件 名: NewsListAdapter
 * 创 建 人: zhangyu
 * 创建日期: 16/12/24 19:55
 * 邮   箱: yuanchong121@gmail.com
 * 修改时间：
 * 修改备注：
 */
public class ClassficationAdapter extends BaseQuickAdapter<ClassFication.DataBeanX.DataBean, BaseViewHolder> {
    public ClassficationAdapter(List<ClassFication.DataBeanX.DataBean> data) {

        super(R.layout.item_classfiy, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, final ClassFication.DataBeanX.DataBean item) {
        ScaleScreenHelperFactory.getInstance().loadView((ViewGroup) helper.convertView);
        helper.setText(R.id.text_nicheng, item.getTitle());
       // helper.setBackgroundColor(R.id.text_nicheng,Color.argb(Double.valueOf("0.3").intValue(), 226, 220, 213));
        View view2=helper.getView(R.id.text_nicheng);
        view2.getBackground().setAlpha(160);//0~255透明度值
    int position = helper.getPosition();

        if (position % 2 == 1) {
            ScaleScreenHelperFactory.getInstance().loadViewMargin(helper.convertView.findViewById(R.id.ll_content), 15, 23, 15, 0);
        } else {
            ScaleScreenHelperFactory.getInstance().loadViewMargin(helper.convertView.findViewById(R.id.ll_content), 15, 23, 15, 0);
        }
        Glide.with(mContext).load(Conn.HOST2 + item.getPicurl()).crossFade().error(R.mipmap.zhanwei).placeholder(R.mipmap.zhanwei).into((ImageView) helper.getView(R.id.img_shouyi));
        View view = helper.getConvertView();
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //   WebActivity.runActivity(mContext, model.desc, model.url);
                Intent intent = new Intent();
                intent.putExtra("goodstype_id", item.getId() + "");
                intent.putExtra("title",item.getTitle());
                intent.setClass(mContext, ClassficationDetailActivity.class);
                mContext.startActivity(intent);
            }
        });
    }

}
